{extend name="common/__base"}

{block name="body"}
<form class="layui-form layui-form-pane">
    <input type="hidden" name="id" value="{$adminInfo.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="username" value="{$adminInfo.username}" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input" name="password" placeholder="不输入则为不修改">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="nickname" value="{$adminInfo.nickname}" lay-verify="required" placeholder="昵称">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit">设置</button>
        </div>
    </div>
</form>
{/block}

{block name="js"}
<script>
    layui.use(['form', 'jquery'], function () {
        let isClick = true;
        let form = layui.form;
        let $ = layui.jquery;

        // 提交
        form.on("submit(submit)", function (obj) {
            if (isClick) {
                isClick = false;
                $.post("{:url('admin/admin/adminInfo')}", $("form").serialize(), function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, function () {
                            location.reload();
                        });
                    } else {
                        isClick = true;
                        layer.msg(res.msg);
                    }
                }, "json");
            } else {
                layer.msg("不允许重复提交");
            }
            return false;
        });
    });
</script>
{/block}